/*
 * @Description: 验证规则配置
 *  
 * @Date: 2021-03-02 10:40:06
 */
// 常用正则表达式
export const reg = {
    // 邮箱
    email: /^([a-zA-Z]|[0-9])(\w|-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/,
    // 手机号码
    mobile: /^1[0-9]{10}$/,
    // 匹配8-16位数字和字母密码
    password: /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{8,16}$/,
    // 电话号码
    tel: /^((\d{3,4}-)|\d{3.4}-)?\d{7,8}$/,
    // 身份证
    idCard: /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/,
    // qq号码
    qq: /[1-9][0-9]{4,}/,
    // ip
    ip: /\d+\.\d+\.\d+\.\d+/,
    // 中文
    zh: /^[\u4e00-\u9fa5]*$/,
    // //匹配由数字和26个英文字母组成的字符串
    letterAnNum: /^[A-Za-z0-9]+$/,
    // 社会统一信用吗
    creditCode: /[1-9A-GY]{1}[1239]{1}[1-5]{1}[0-9]{5}[0-9A-Z]{10}/,
    // 电话或者手机
    telOrmobile: /(^((\d{3,4}-)|\d{3.4}-)?\d{7,8}$)|(^1[0-9]{10}$)/,
    // 特殊字符
    // special: new RegExp("[a-zA-Z0-9\_\u4e00-\u9fa5]","i"),
    special: /^[a-zA-Z0-9\_\u4e00-\u9fa5]*$/,
    // url验证
    url: /^(((http|https):)?\/\/)?[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!\$&'\*\+,;=.]+$/,
}

// 验证规则配置
export default {
    username: [// 用户名验证
        { required: true, message: '请输入用户名!' }
    ],
    password: [// 密码验证
        { required: true, message: '请输入密码!' }
    ],
    scoreName: [// 评价名称
      { required: true, message: '请输入评价名称', trigger: 'blur' },
      { min: 1, max: 20, message: '长度在 1 到 20 个字符', trigger: 'blur' }
    ],
    scoreDescribe: [ // 评价描述
      { min: 0, max: 50, message: '长度小于 50 个字符', trigger: 'blur' }
    ],
    scoreContent: [
      { required: true, message: '请输入评价内容', trigger: 'blur' },
      { pattern: /^[\u4e00-\u9fa5]{1,20}$/, message: "请输入1到20个汉字", trigger: "blur",}
    ],
    scoreDate: [
      { required: true, message: '请选择时间范围', trigger: 'blur' },
    ],
    commentType: [{ required: true, message: '请选择是否关联订单', trigger: 'blur' }],
    mobile: [
      { pattern: reg.mobile, message: "请输入正确的手机号", trigger: "blur",}
    ],
    email: [
      { pattern: reg.email, message: "请输入正确的邮箱", trigger: "blur",}
    ],
    storeContactUser: [
      { min: 0, max: 50, message: '长度小于 50 个字符', trigger: 'blur' }
    ],
    creditCode: [
      { pattern: reg.creditCode, message: "请输入正确社会统一信用吗", trigger: "blur",}
    ],
    idCard: [
      { pattern: reg.idCard, message: "请输入正确的身份证号", trigger: "blur",}
    ],
    must: [ // 必填项
      { required: true, message: '请输入!' }
    ],
    telOrmobile: [
      { pattern: reg.telOrmobile, message: "请输入正确的电话或者手机号", trigger: "blur",}
    ],
    imgUrl: [
      { pattern: reg.url, message: "请上传正确的图片链接", trigger: "blur",}
    ],
    link: [
      { pattern: reg.url, message: "请输入正确链接", trigger: "blur",}
    ],
    name: [
      { required: true, message: '请输入名称' },
    ],
    zh: [
      { pattern: reg.zh, message: "请输入中文字符", trigger: "blur",}
    ],
    letterAnNum: [
      { pattern: reg.letterAnNum, message: "请输入数字或者字母", trigger: "blur",}
    ],
    special:  [
      { pattern: reg.special, message: "不能包含特殊字符", trigger: "blur",}
    ],
}